package com.jf.ollama.service;

import jakarta.activation.MimeType;
import jakarta.annotation.Resource;
import org.mockito.internal.configuration.ClassPathLoader;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.content.Media;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.ollama.api.OllamaApi;
import org.springframework.ai.ollama.api.OllamaModel;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.util.MimeTypeUtils;

import java.io.IOException;


/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2025-06-14
 * Time:0:56
 */
@Service
public class MultiService {
    @Resource
    private OllamaChatModel qwenModel;
    @Resource
    private OllamaChatModel deepSeekModel;

    public String deepSeek(String message) {
        return deepSeekModel.call(message);
    }

    public String qwen(String message) {
        return qwenModel.call(message);
    }

    public String chatAndMedia(String message, String mediaUrl) {
        ClassPathResource resource = new ClassPathResource(mediaUrl);
        UserMessage userMessage = UserMessage.builder()
                .text(message)
                .media(Media.builder()
                        .mimeType(MimeTypeUtils.IMAGE_PNG)
                        .data(resource)
                        .build())
                .build();
        return qwenModel.call(userMessage);
    }
}
